<?php
namespace app\supermanager\validate;
use think\Validate;
class Filiale extends Validate 
{
	protected $rule = [
	    'mobile'            => 'require|checkMobile',
        'telephone'         => 'require',
        'id_card'           => 'require|checkIdCard',
        'email'             => 'require|email',
        'address'           => 'require'
    ];
    protected $message = [
    	'mobile.require'             =>  '负责人电话不能为空',
        'telephone'                  =>  '固定电话不能为空',
        'id_card.require'            =>  '身份证号不能为空',
        'address'                    =>  '地址不能为空',
        'email.require'              =>  '邮箱不能为空',
        'email.email'				 =>  '邮箱格式错误'
    ];	
	
	protected  function checkMobile($value){
		if(false === Validate::regex($value,'/^(13[0-9]|14[5|7]|15[0-9]|18[0-9]|17[0-9])\d{8}$/'))
		{
			return '负责人电话格式错误';
		}
		return true;
	}
	protected  function checkIdCard($value){
		if(false === Validate::regex($value,'/^[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}$|^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}([0-9]|X)$/i'))
		{
			return '身份证号格式错误';
		}
		return true;
	}
}

?>